<?php
require_once('include/connect.inc.php');?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="match_test_add.php">
  <table width="831" border="1">
    <tr>
      <td width="522">คำถาม</td>
      <td width="293">ตัวเลือก</td>
    </tr>
    <tr>
      <td height="39" valign="top">
      <table width="526" border="1">
 <?
 $number=0;
$query3 = query("SELECT * FROM tb_set_detail where set_id='".$_GET['set_id']."'");
    	while ($rs3 = fetch_array($query3)) {
		$question_id3=$rs3['question_id'];
$query2= query("SELECT * FROM tb_question where question_id='".$question_id3." ' ");
	while ($rs2 = fetch_array($query2)) {
		$question_id=$rs2['question_id'];
		$question_detail=$rs2['question_detail'];
		$number++;
		print_r($question_id);
?>
<? }?>
          <tr>
            <td width="465" valign="top">ข้อ <? echo $number;?>. <? echo $question_detail;?><? echo $question_id;?> </td>
            <td width="41"  height="25" valign="top">
<select name="selecta[<?=$i?>]" id="selecta">
<?
$query4 = query("SELECT * FROM tb_set_detail where set_id='".$_GET['set_id']."'");
    	while ($rs4 = fetch_array($query4)) {
		$question_id4=$rs4['question_id'];
$query2= query("SELECT * FROM tb_choice where answer>=2  and question_id=$question_id4 ");
		while ($rs2 = fetch_array($query2)) {
			$question_id=$rs2['question_id'];
			$question_detail=$rs2['question_detail'];
			$choice_detail=$rs2['choice_detail'];
			$choice_id=$rs2['choice_id'];
			print_r($question_id);
			?>
              <option value="<?=$choice_id?>"><?=$choice_detail?></option>
              <?php
		$i++;
		}
	}
?>
            </select></td>
          </tr>
<? }?>
        </table>
      </td>
      <td valign="top">
      <table width="293" border="1">
<?
echo $number;
 $query5 = query("SELECT * FROM tb_set_detail where set_id='".$_GET['set_id']."'order by RAND()");
    	while ($rs5 = fetch_array($query5)) {
		$question_id5=$rs5['question_id'];
		}
$i=0;
$query= query("SELECT * FROM tb_choice where answer>=2 order by RAND()");
	while ($rs = fetch_array($query)) {
		$answer=$rs['answer'];
		$choice_id=$rs['choice_id'];
		$choice_detail=$rs['choice_detail'];
		print_r($choice_id);
?>
          <tr>
            <td width="283" height="25" valign="top"><? echo $choice_detail;?> <? echo $choice_id;?>
            <input type="hidden" name="hiddenField[]" id="hiddenField[]" value="<? echo $choice_id;?>"></td>
          </tr>
 <? }?>
        </table>
      </td>
    </tr>
  </table>
  <input type="submit" name="button" id="button" value="ส่ง" />
</form>
</body>
</html>
